package com.example.saveqqpassword;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class SaveQQInfo {
    private static String unm = "username";
    private static String pwd = "password";
    private static String fileName = "QQInfo";
    public  static boolean saveQQInfo(Context context,String username ,String password){
        SharedPreferences sharedPreferences = context.getSharedPreferences(fileName,Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sharedPreferences.edit();
        edit.putString(unm,username);
        edit.putString(pwd,password);
        edit.commit();
        return true; //操作是否成功
    }

    public static Map<String,String> getQQInfo(Context context){
        SharedPreferences sharedPreferences = context.getSharedPreferences(fileName,Context.MODE_PRIVATE);
        String username = sharedPreferences.getString(unm,null);
        String password = sharedPreferences.getString(pwd,null);
        Map<String,String> userInfoMap = new HashMap<String, String>();
        userInfoMap.put(unm,username);
        userInfoMap.put(pwd,password);
        return userInfoMap;
    }
}
